﻿<!doctype html>
<html>
	<head>
		<title>羽乐汇</title>
		<meta name="keywords" content="羽毛球，球会，球场，教练">
		<meta name="charset" content="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1" />
		<link rel="stylesheet" type="text/css" href="__PUBLIC__/CSS/HomePage/bootstrap.min.css">
		<link rel="stylesheet" type="text/css" href="__PUBLIC__/CSS/HomePage/index.css">
		
		<script type="text/javascript" src="__PUBLIC__/JS/HomePage/jquery.min.js"></script>
		
		<script type="text/javascript" src="__PUBLIC__/JS/HomePage/bootstrap.min.js"></script>
    </head>
	<body>
	<!-- ---------------------------------------------------------------pc_index--------------------------------------------------------- -->
		<div class="pc_coach container-fluid">
		<div class="top visible-lg visible-md">
			<div class="ttop">
				<span>欢迎来到羽乐汇</span>
				<div>
					<span class="wellcome"></span>
					<span class="login">
						<button class="login_btn">登陆</button>
						<!-- <button class="notlogin_btn">注销</button> -->
						<a href="<{:U('Index/registration')}>">注册</a>
						
					</span>
					<!-- <button class="sign_btn">注册</button> -->
					<a class="login_after" href="<{:U('User/index')}>">个人主页</a>
					<a href="__PUBLIC__/HTML/vip_center.html">vip中心</a>
				</div>
			</div>
			<div>
				<img src="__PUBLIC__/PICTURE/HomePage/logo.jpg">
			</div>
			<div class="main_nav">
				<ul>
					<li><a href="<{:U('Index/index')}>">首页</a></li>
					<li><a href="<{:U('Gymnasium/index')}>">球场</a></li>
					<li><a href="<{:U('Club/index')}>">球会</a></li>
					<li>培训</li>
					<li><a href="<{:U('Activity/activity')}>">活动</a></li>
					<li><a href="<{:U('Coach/index')}>">教练</a></li>
					<li>竞赛</li>
					<li><a href="<{:U('Announce/index')}>">公告</a></li>
				</ul>
			</div>
		</div>
			<header class="row visible-xs visible-sm header_nav container-fluid">
				<a href="<{:U('Index/index')}>"><img src="__PUBLIC__/PICTURE/HomePage/pre.png"/></a>
				<span>教练页面</span>
			</header>
			<div class="search_content">
				<div class="top_search">
					<form action=" " name="search_form" method="post" >
						<select name="search_type" class="ui-select search_type f_l">
							<option value="1" {if $search_type eq 1}selected="selected"{/if}>搜教练</option>
						</select>
						<input type="text" name="search_keyword" class="" holder="请输入您要搜索的关键词" id="searchword" value="" />
						<button class="" rel="search_btn" id="searchbutton" type="button">搜索</button>
					</form>
				</div>
			</div>
			<div class="coach_content">
				<div class="coach_nav">
					<ul class="row list-unstyled">
						<!--<li class="col-lg-1 col-md-1">
							<div class="form-group">
								<select class="form-control">
									<option value="">星期一</option>
							         <option value="">星期二</option>
							         <option value="">星期三</option>
							         <option value="">星期四</option>
							         <option value="">星期五</option>
							         <option value="">星期六</option>
							         <option value="">星期天</option>
	      						</select>
							</div>
						</li>
						<li class="col-lg-1 col-md-1">
							<div class="form-group">
								<select class="form-control">
	         						<option value="">6：00-7：00</option>
							        <option value="">7：00-8：00</option>
							        <option value="">8：00-9：00</option>
							        <option value="">9：00-10：00</option>
	      						</select>
							</div>
						</li> -->
					</ul>
				</div>
				<div class="coach_messege">
					<div class="coach_me">
					<div id="total0" style="display:none;">
						<ul>
							<li id="img0"></li>
							<li id="name0"><span>教练：</span></li>
							<li id="descrition0"><span>描述：</span></li>
							<li id="phone0"><span>电话:</span></li>
							<li id="detail0"></li>
						</ul>
					</div>
					<div id="total1" style="display:none;">
						<ul>
							<li id="img1"></li>
							<li id="name1"><span>教练：</span></li>
							<li id="descrition1"><span>描述：</span></li>
							<li id="phone1"><span>电话:</span></li>
							<li id="detail1"></li>
						</ul>
					</div>
					<div id="total2" style="display:none;">
						<ul>
							<li id="img2"></li>
							<li id="name2"><span>教练：</span></li>
							<li id="descrition2"><span>描述：</span></li>
							<li id="phone2"><span>电话:</span></li>
							<li id="detail2"></li>
						</ul>
					</div>
					<div id="total3" style="display:none;">
						<ul>
							<li id="img3"></li>
							<li id="name3"><span>教练：</span></li>
							<li id="descrition3"><span>描述：</span></li>
							<li id="phone3"><span>电话:</span></li>
							<li id="detail3"></li>
						</ul>
					</div>
					<div id="total4" style="display:none;">
						<ul>
							<li id="img4"></li>
							<li id="name4"><span>教练：</span></li>
							<li id="descrition4"><span>描述：</span></li>
							<li id="phone4"><span>电话:</span></li>
							<li id="detail4"></li>
						</ul>
					</div>
							
				</div>
				</div>
				<div class="content_foot">
					<ul>
						<li><button class="pageup" type="button" disabled="disabled">上一页</button></li>
						<li><button class="pagedown" type="button" disabled="disabled">下一页</button></li>
					</ul>
				</div>
			</div>
		</div>
		<div class="foot row">
			<div>
				<p>联系我们</p>
				<p>关于我们</p>
				<p>加入我们</p>
			</div>
			<div>
				<p>电话：400-800-8888 周一至周六9：00-18：00</p>
				<p>[羽乐汇]<a href="http://oto.my3w.com">http://oto.my3w.com</a></p>
			</div>
		</div>
		<script type="text/javascript">
		var page_num=1;  //当前页数
		var totalPage;
		var coach_count;  //后台返回教练条数
		var coachJson;  //教练内容Json数组
		var pagetype=0;


		<!------------------打开页面异步加载教练------------------>

		$(function(){
			$.post('__URL__/listAllCoach',{'page_num':page_num},function(resultList){
				page_num=resultList.page_num;
				coach_count=resultList.coach_count;
				coachJson=resultList.result;
    	},'json');
			setTimeout("setpage()",200); 
		});
		function setpage(){
			totalPage=Math.ceil(coach_count/5);
			if(page_num>1){
				$(".pageup").attr('disabled',false);
			}
			else{
				$(".pageup").attr('disabled',true);
			}
			if(totalPage>page_num){
				$(".pagedown").attr('disabled',false);
			}
			else{
				$(".pagedown").attr('disabled',true);
			}
			if(page_num<totalPage){
				for (var i = 0; i <= 4; i++) {
					var img="#img"+i;
					var name="#name"+i;
					var descrition="#descrition"+i;
					var detail="#detail"+i;
					var phone="#phone"+i;
					var total="#total"+i;
					var coach_picture=coachJson[i].coach_picture;
					var id=coachJson[i].coach_id;
					var detailurl="<{:U('Coach/coachDetail')}>"+"&coach_id="+id;
					$(total).css('display','block');
					$(img).html('<img src="'+coach_picture+'">');
					$(name).html('<span>教练：'+coachJson[i].name[0].name+'</span>');
					$(descrition).html('<span>描述：'+coachJson[i].coach_description+'</span>');
					$(phone).html('<span>电话:'+coachJson[i].coach_phone+'</span>');
					$(detail).html('<a href='+detailurl+'>详情</a>');
				}
			}
			else{
				for (var i = 0; i <= coach_count-(page_num-1)*5-1; i++) {
					var img="#img"+i;
					var name="#name"+i;
					var descrition="#descrition"+i;
					var detail="#detail"+i;
					var phone="#phone"+i;
					var total="#total"+i;
					var coach_picture=coachJson[i].coach_picture;
					var id=coachJson[i].coach_id;
					var detailurl="<{:U('Coach/coachDetail')}>"+"&coach_id="+id;
					$(total).css('display','block');
					$(img).html('<img src="'+coach_picture+'">');
					$(name).html('<span>教练：'+coachJson[i].name[0].name+'</span>');
					$(descrition).html('<span>描述：'+coachJson[i].coach_description+'</span>');
					$(phone).html('<span>电话:'+coachJson[i].coach_phone+'</span>');
					$(detail).html('<a href='+detailurl+'>详情</a>');
				}
				for(var i = coach_count-(page_num-1)*5; i <= 4; i++){
					var img="#img"+i;
					var name="#name"+i;
					var descrition="#descrition"+i;
					var detail="#detail"+i;
					var phone="#phone"+i;
					var total="#total"+i;
					$(total).css('display','none');
					$(img).html('');
					$(name).html('');
					$(descrition).html('');
					$(phone).html('');
					$(detail).html('');
				}
			}
		}
		//上一页
		$('.pageup').bind('click',function(){
			if(pagetype==0){
			page_num--;
			$.post('__URL__/listAllCoach',{'page_num':page_num},function(resultList){
				page_num=resultList.page_num;
				coach_count=resultList.coach_count;
				coachJson=resultList.result;
    	},'json');
			setTimeout("setpage()",200); 
		}
		else{
			page_num--;
			var name=$("#searchword").val();
			$.post('__URL__/coachSearch',{'coach_name':name,'page_num':page_num},function(resultList){
				page_num=resultList.page_num;
				coach_count=resultList.resultCount;
				coachJson=resultList.result;
    	},'json');
			setTimeout("setpage()",200); 
		}
		});
		//下一页
		$('.pagedown').bind('click',function(){
			if(pagetype==0){
			page_num++;
			$.post('__URL__/listAllCoach',{'page_num':page_num},function(resultList){
				page_num=resultList.page_num;
				coach_count=resultList.coach_count;
				coachJson=resultList.result;
    	},'json');
			setTimeout("setpage()",200); 
		}
		else{
			page_num++;
			var name=$("#searchword").val();
			$.post('__URL__/coachSearch',{'coach_name':name,'page_num':page_num},function(resultList){
				page_num=resultList.page_num;
				coach_count=resultList.resultCount;
				coachJson=resultList.result;
    	},'json');
			setTimeout("setpage()",200); 
		}
		});

<!----------调用百度API返回位置信息------------>
		function getLocation(){
			if (navigator.geolocation){
				navigator.geolocation.getCurrentPosition(showPosition,showError);
			}else{
		alert("浏览器不支持地理定位。");
			}
		}
		function showPosition(position){ 
    	var latlon = position.coords.latitude+','+position.coords.longitude; 
     
    	//baidu 
    		var url = "http://api.map.baidu.com/geocoder/v2/?ak=C93b5178d7a8ebdb830b9b557abce78b&callback=renderReverse&location="+latlon+"&output=json&pois=0"; 
   		 $.ajax({  
       		 type: "GET",  
       		 dataType: "jsonp",  
       		 url: url, 
      		  beforeSend: function(){ 
         		   $("#baidu_geo").html('正在定位...'); 
       		 }, 
        		success: function (json) {  
          		  if(json.status==0){ 
          		      $("#baidu_geo").html(json.result.addressComponent.city); 
          		      province=json.result.addressComponent.province;
          		      city=json.result.addressComponent.city;
          		      district=json.result.addressComponent.district;
          		  } 
      		  }, 
       		 error: function (XMLHttpRequest, textStatus, errorThrown) {  
       		     $("#baidu_geo").html(latlon+"地址位置获取失败");  
       		 } 
   		 }); 
		} 
		function showError(error){
			switch(error.code) {
				case error.PERMISSION_DENIED:
					alert("定位失败,用户拒绝请求地理定位");
					break;
				case error.POSITION_UNAVAILABLE:
					alert("定位失败,位置信息是不可用");
					break;
				case error.TIMEOUT:
					alert("定位失败,请求获取用户位置超时");
					break;
				case error.UNKNOWN_ERROR:
					alert("定位失败,定位系统失效");
					break;
 		   }
		}

		//getLocation();
		<!------------------搜索------------------>
		$("#searchbutton").bind("click",function(){
  			var name=$("#searchword").val();
  			page_num=1;
  			pagetype=1;
  			$.post('__URL__/coachSearch',{'coach_name':name,'page_num':page_num},function(resultList){
				page_num=resultList.page_num;
				coach_count=resultList.resultCount;
				coachJson=resultList.result;
    	},'json');
			setTimeout("setpage()",200); 
		});

		</script>
	</body>
</html>